package top.continew.admin.webapi.sport;

import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import top.continew.admin.sport.model.resp.ProjectEntryResp;
import top.continew.starter.extension.crud.enums.Api;

import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.web.bind.annotation.*;

import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.admin.sport.model.query.ProjectEntryGradeQuery;
import top.continew.admin.sport.model.req.ProjectEntryGradeReq;
import top.continew.admin.sport.model.resp.ProjectEntryGradeDetailResp;
import top.continew.admin.sport.model.resp.ProjectEntryGradeResp;
import top.continew.admin.sport.service.ProjectEntryGradeService;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
import top.continew.starter.web.model.R;

import java.util.List;

/**
 * 比赛成绩管理 API
 *
 * @author xiahaike
 * @since 2024/09/15 12:52
 */
@Tag(name = "比赛成绩管理 API")
@RestController
@CrudRequestMapping(value = "/sport/projectEntryGrade", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
public class ProjectEntryGradeController extends BaseController<ProjectEntryGradeService, ProjectEntryGradeResp, ProjectEntryGradeDetailResp, ProjectEntryGradeQuery, ProjectEntryGradeReq> {

    @Resource
    private ProjectEntryGradeService projectEntryGradeService;

    @Operation(summary = "分页查询列表", description = "分页查询列表")
    @ResponseBody
    @GetMapping
    @Override
    public R<PageResp<ProjectEntryGradeResp>> page(ProjectEntryGradeQuery projectEntryGradeQuery, @Validated PageQuery pageQuery) {
        this.checkPermission(Api.LIST);
        PageResp<ProjectEntryGradeResp> projectEntryGradeRespPageResp = projectEntryGradeService.myPage(projectEntryGradeQuery, pageQuery);
        return R.ok(projectEntryGradeRespPageResp);
    }

    @Operation(summary = "查询还没有成绩的参赛者或团队列表", description = "查询还没有成绩的参赛者或团队列表")
    @ResponseBody
    @GetMapping("/noGrade/{projectId}")
    public R<List<ProjectEntryResp>> noGrade(@PathVariable Long projectId) {
        this.checkPermission(Api.LIST);
        List<ProjectEntryResp> ProjectEntryResp = projectEntryGradeService.noGrade(projectId);
        return R.ok(ProjectEntryResp);
    }
}